import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        Stack<Integer> s1=new Stack<>();
        Stack<Character> s2=new Stack<>();
        int n=sc.nextInt();
        for(int i=0;i<n;i++){
            s1.push(sc.nextInt());
        }
        for(int i=0;i<n-1;i++){
            s2.push(sc.next().charAt(0));
        }
        int res=0;
        int ret=0;
        boolean flg=false;
        while(!s2.isEmpty()){
            int n1=s1.pop();
            int n2=s1.pop();
            char ch=s2.pop();
            if(ch=='+'){
                res=n2+n1;
            }
            if(ch=='-'){
                res=n2-n1;
            }
            if(ch=='*'){
                res=n2*n1;
            }
            if(ch=='/'){
                if(n1==0){
                    flg=true;
                    ret=n2;
                    break;
                }
                res=n2/n1;
            }
            s1.push(res);
        }
        if(flg){
            System.out.println("ERROR: "+ret+"/0");
        }else{
            System.out.println(res);
        }
    }
    /**
     * 简写单词
     * @param args
     */
    public static void main2(String[] args) {
        Scanner in = new Scanner(System.in);
        String str=in.nextLine();
        String s=str.toUpperCase();
        String[] arr=s.split(" ");
        for(int i=0;i<arr.length;i++){
            System.out.print(arr[i].charAt(0));
        }
    }
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();
        String[] strs=new String[n];
        String str1=in.next();
        String str2=in.next();
        for(int i=0;i<n;i++){
            strs[i]=in.next();
        }
        int ret1=-1;
        int ret2=-1;
        int min=1000000;
        int res=1000000;
        for(int i=0;i<n;i++){
            if(strs[i].equals(str1)||strs[i].equals(str2)){
                if(strs[i].equals(str1)){
                    ret1=i;
                }else{
                    ret2=i;
                }
            }
            if(ret1!=-1&&ret2!=-1){
                min=Math.abs(ret1-ret2);
                res=Math.min(res,min);
            }
        }
        if(res==1000000){
            System.out.println(-1);
        }else{
            System.out.println(res);
        }
    }

}